// const toast = require('./utils/toast/index')
require("./utils/batch")
const config = require('config')
const http = require("./utils/http2")
const wxToast = require("./utils/wx-toast")
const toPromise = require("./utils/to-promise")
const checkShare = require("./utils/share")

App({
    onLaunch: function () {
        wx.getSystemInfo({
            success: (res) => {
                this.window = { width: res.windowWidth, height: res.screenHeight }
            }
        })
        const config = wx.getExtConfigSync("storeId")
        if (config.storeId) {
            this.storeId = config.storeId
        }
    },
    global_data: {},
    // toast,
    http,
    config,
    wxToast,
    toPromise,
    setGlobal: function (k, v) {
        this.global_data[k] = v
    },
    checkShare,
    getShareObj(title = "", params = {}) {
        const id = wx.getStorageSync('mid')
        if (!id) {
            return {

            }
        }
        const paramsArr = ["shareId=" + id]
        Object.keys(params).forEach(k => {
            paramsArr.push(k + "=" + params[k])
        })
        const ps = getCurrentPages()
        return {
            title,
            path: "/" + ps[ps.length - 1].route + "?" + paramsArr.join("&")
        }
    },
    storeId: 889419
})
